<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>E键配</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <link href="./static/plugins/bootstrap/bootstrap.min.css" rel="stylesheet">
    <link href="./static/css/font-awesome.min.css" rel="stylesheet">
    <link href="./static/plugins/toastr/toastr.min.css" rel="stylesheet">
    <link href="./static/css/animate.css" rel="stylesheet">
    <link href="./static/css/style.css" rel="stylesheet">

    <script type="text/javascript" src="./static/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" href="./static/plugins/bootstrap/bootstrap.min.js"></script>
    <script type="text/javascript" src="./static/plugins/toastr/toastr.min.js"></script>
    <script type="text/javascript" src="./static/plugins/validate/jquery.validate.min.js"></script>
    <script type="text/javascript" src="./static/js/main.js"></script>
    <script>
        if (token && token.length > 30) {
            location.href = '/container.html';
        }
    </script>
</head>
<body class="gray-bg">
<div class="middle-box text-center loginscreen animated fadeInDown">
    <div>
        <div>
            <img class="logo-name"
                 src=""
                 alt="E键配">
        </div>
        <!--<h3>E键配</h3>-->
        <p class="m-t">郑州畅配网络科技有限公司</p>
        <form class="m-t m-b" role="form" id="theForm">
            <div class="form-group">
                <input type="text" name="phone" class="form-control" placeholder="请输入手机号">
            </div>
            <div class="form-group">
                <input type="password" name="password" class="form-control" placeholder="请输入密码">
            </div>
            <input type="hidden" name="from" value="pc"/>
            <button type="submit" class="btn btn-primary block full-width m-b">登&nbsp;录</button>

            <a class="btn btn-sm btn-success btn-outline btn-block" href="reg.html">用户注册</a>
        </form>
        <a href="reset.html">
            <small>忘记密码?</small>
        </a>
    </div>
</div>

<script>
    $(function () {
        $('#theForm').validate({
            rules: {
                phone: {
                    required: true
                },
                password: {
                    required: true,
                }
            },
            messages: {
                phone: {
                    required: '<i class="icon icon-exclamation-sign"></i>用户名不能为空'
                },
                password: {
                    required: '<i class="icon icon-exclamation-sign"></i>密码不能为空',
                }
            },
            submitHandler: function (form) {
                $.ajax({
                    type: 'POST',
                    url: api + "index/login",
                    data: $(form).serialize(),
                    dataType: 'json',
                    success: function (data) {
                        if (data.ret == 0) {
                            setItem('token', data.data.token);
                            setItem('info', data.data.info);
                            location.href = "/container.html";
                        } else {
                            toastr.error(data.msg);
                        }
                    },
                    error: function (xhr, type) {
                        toastr.error(xhr.responseJSON.msg);
                    }
                });
            }
        });
    });

</script>
</body>
</html>
